<?php

use iflow\swoole\implement\Services\Dht\implement\Events\Event;

return [
    'services' => [
        'swConfig' => [
            'pid_file'              => runtime_path() . 'dht.pid',
            'log_file'              => runtime_path() . 'dht.log',
            'daemonize'             => false,
            'reactor_num'           => swoole_cpu_num(),
            'worker_num'            => swoole_cpu_num(),
            'task_worker_num'       => swoole_cpu_num(),
            'dispatch_mode' => 1,
            'max_conn' => 65535,
            'heartbeat_check_interval' => 5,
            'heartbeat_idle_time' => 10,
            'task_max_request' => 0
        ],
        'handle' => '',
        'event' => Event::class,
        'node' => [
            // 最大存储节点数量
            'node_size' => 200,
            // 主动获取节点 500 ms
            'auto_find' => 5000,
            'fields' => [
                [ 'name' => 'ip', 'type' => \Swoole\Table::TYPE_STRING, 'size' => 25 ],
                [ 'name' => 'id', 'type' => \Swoole\Table::TYPE_INT ],
                [ 'name' => 'index', 'type' => \Swoole\Table::TYPE_STRING, 'size' => 25 ],
                [ 'name' => 'p', 'type' => \Swoole\Table::TYPE_INT ],
                [ 'name' => 'info', 'type' => \Swoole\Table::TYPE_STRING, 'size' => 2048 ]
            ],
            'bootstrapNodes' => [
                [ 'router.bittorrent.com', 6881 ],
                [ 'dht.transmissionbt.com', 6881 ],
                [ 'router.utorrent.com', 6881 ]
            ]
        ],
        'listener' => [
            'host' => '0.0.0.0',
            'port' => 0,
            'mode' => SWOOLE_PROCESS,
            'sockType' => SWOOLE_SOCK_UDP
        ]
    ]
];